package com.cjb.cloudsystem.convert.Impl;

import com.cjb.cloudsystem.convert.SysMenuConvert;
import com.cjb.cloudsystem.entity.SysMenu;
import com.cjb.cloudsystem.vo.SysMenuVO;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author chenjinbin
 * @Package IntelliJ IDEA
 * @Class SysMenuConvertImpl
 * @Date 2023-09-23 22:12
 */
@Service
public class SysMenuConvertImpl implements SysMenuConvert {

    /**
     *构建树节点
     */
    @Override
    public List<SysMenuVO> convertList(List<SysMenu> list) {
        if (list == null) {
            return null;
        }

        List<SysMenuVO> list1 = new ArrayList<SysMenuVO>(list.size());
        for (SysMenu sysMenu : list) {
            list1.add(convert(sysMenu));
        }
        return list1;
    }

    @Override
    public SysMenuVO convert(SysMenu entity) {
        if (entity == null) {
            return null;
        }

        SysMenuVO sysMenuVO = new SysMenuVO();

        sysMenuVO.setId(entity.getId());
        sysMenuVO.setPid(entity.getPid());
        sysMenuVO.setName(entity.getName());
        sysMenuVO.setUrl(entity.getUrl());
        sysMenuVO.setType(entity.getType());
        sysMenuVO.setOpenStyle(entity.getOpenStyle());
        sysMenuVO.setIcon(entity.getIcon());
        sysMenuVO.setAuthority(entity.getAuthority());
        sysMenuVO.setSort(entity.getSort());
        sysMenuVO.setCreateTime(entity.getCreateTime());

        return sysMenuVO;
    }
}
